/*package com.san.simulation.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

import com.san.simulation.api.PathResolver;
import com.san.simulation.api.ProcessDeployer;
import com.san.simulation.model.api.Element;
import com.san.simulation.model.api.ElementType;
import com.san.simulation.model.api.Path;
import com.san.simulation.model.api.ProcessDefinition;
import com.san.simulation.model.impl.ActivitiProcessElement;
import com.san.simulation.model.impl.Model;

public class Service {

	// private static final String BPMN_DIAGRAM_LOCATION =
	// "ExclusiveGatewayModel.bpmn20.xml";

	private static final String BPMN_DIAGRAM_LOCATION = "makercheckerRevised.bpmn20.xml";

	BpmnParse parse = null;

	Map<String, Element> elementMap = new HashMap<String, Element>();
	Map<String, List<Element>> transMap = new HashMap<String, List<Element>>();

	List<Model> sequence = new ArrayList<Model>();

	Map<String, Model> flowPaths = new HashMap<String, Model>();

	List<Path> paths = null;

	public List<Model> getProcessDefinition() {
		ProcessDeployer deployer = new ActivitiProcessDeployer();
		parse = deployer.buildProcessDefinition(BPMN_DIAGRAM_LOCATION);
		ProcessDefinition definition = deployer.getProcessDefinitions(parse);

		PathResolver resolver = new ActivitiPathResolver();

		paths = resolver.resolvePath(definition);

		System.out.println(paths.size());

		int counter = 0;
		for (Path path : paths) {

			System.out.println(path.getPathElements());

			Model flowPath = new Model();

			for (Element element : path.getPathElements()) {

				if (!element.getType().equalsIgnoreCase(
						ElementType.SEQUENCE_FLOW.getStringValue())) {

					System.out
							.println("-----------------------------------------"
									+ element.getName());

					flowPath.addElement(element);

				}

				if (((ActivitiProcessElement) element).getElement() != null) {

					elementMap.put(element.getId(), element);

				}

				if (((ActivitiProcessElement) element).getTransition() != null) {

					if (transMap.get(element.getSource().getId()) == null) {
						transMap.put(element.getSource().getId(),
								new ArrayList<Element>());

					}
					transMap.get(element.getSource().getId()).add(element);

				}

				
				 * if (((ActivitiProcessElement) element).getElement() != null)
				 * {
				 * 
				 * // System.out.println(element); ((ActivitiProcessElement)
				 * element).getElement() .setProperty("name", "sankar"); } else
				 * { ((TransitionImpl) (((ActivitiProcessElement) element)
				 * .getTransition())).setProperty("name", "test"); }
				 

			}

			++counter;

			flowPaths.put("Path-" + counter, flowPath);
		}

		System.out.println(transMap);
		System.out.println(elementMap);

		TreeNode root = new DefaultTreeNode();
		// createModelPath("theStart", null);

		getSequence(null);

		for (Model model : sequence) {
			System.out.println(model.getElementList());
		}

		return sequence;
	}

	public Map<String, Model> getFlowPath() {

		int counter = 0;
		for (Path path : paths) {

			System.out.println(path.getPathElements());

			Model flowPath = new Model();

			for (Element element : path.getPathElements()) {

				if (!element.getType().equalsIgnoreCase(
						ElementType.SEQUENCE_FLOW.getStringValue())) {

					System.out
							.println("-----------------------------------------"
									+ element.getName());

					flowPath.addElement(element);

				}
			}

			++counter;

			flowPaths.put("Path-" + counter, flowPath);
		}

		return flowPaths;

	}

	public void createModel(String startId, TreeNode parent) {

		TreeNode node = new DefaultTreeNode(elementMap.get(startId), parent);
		if (transMap.get(startId) != null) {
			for (Element trans : transMap.get(startId)) {
				if (trans.getDestination() != null) {
					createModel(trans.getDestination().getId(), node);
				}
			}
		}

	}

	public void getSequence(Element parent) {

		String e_id = null;

		e_id = parent == null ? "startevent1" : parent.getDestination().getId();

		System.out.println(e_id);
		Element item = null;
		List<Element> transition = null;
		
		 * if (parent == null) {
		 * 
		 * System.out.println("A"); Model model = new Model(); Set<Element>
		 * items = new LinkedHashSet<Element>(); item = elementMap.get(e_id);
		 * 
		 * items.add(item); model.setElement(items); if (!containsSeq(e_id)) {
		 * sequence.add(model); }
		 * 
		 * transition = transMap.get(e_id);
		 * 
		 * } else {
		 

		System.out.println("B");

		transition = transMap.get(e_id);
		Model model = new Model();
		Set<Element> items = new LinkedHashSet<Element>();

		if (transition != null) {
			for (Element tranItem : transition) {
				item = elementMap.get(tranItem.getDestination().getId());

				System.out.println(item.getId() + "***************"
						+ item.getType() + "**********"
						+ ElementType.PARALLEL_GATEWAY.getStringValue());
				if (item.getType().contains("ateway")
				 (ElementType.PARALLEL_GATEWAY.getStringValue()) ) {
					System.out.println("in " + item.getId());
					for (Element tranItemInner : item.getOutgoingTransitions()) {
						item = elementMap.get(tranItemInner.getDestination()
								.getId());
						if (!containsSeq(item.getId())) {
							items.add(item);
						}

					}

				} else {
					if (!containsSeq(item.getId())) {
						items.add(item);
					}
				}
			}
		}
		// end if

		System.out.println("^^^^^^^^^^^^^^" + e_id + "^^^^^^^^^" + items
				+ "^^^^");
		model.setElements(items);
		if (model.getElements().size() > 0) {
			sequence.add(model);
		}

		// }

		if (transition != null) {
			getSequence(transition.get(0));
		}

	}

	public boolean containsSeq(String id) {

		if (id.equals("theStart") || id.equals("theEnd")) {

			return true;
		}

		for (Model model : sequence) {
			for (Element element : model.getElements()) {
				if (element.getId().equalsIgnoreCase(id)) {
					return true;
				}

			}
		}

		return false;

	}

	public static void main(String[] args) {
		Service service = new Service();
		System.out.println(service.getProcessDefinition());
	}
}
*/